import {h} from 'vue'

export function useDialog(options) {
  const {type, title, content, loading, confirm, cancel} = options
  $dialog.create({
    type: type || 'primary',
    title: title || '',
    content: () => h('div', {
      class: 'pb-6'
    }, {default: () => content || ''}),
    positiveText: '确定',
    showIcon: false,
    maskClosable: false,
    loading: loading || false,
    positiveButtonProps: {
      type: type || 'primary',
      size: 'large'
    },
    negativeText: '取消',
    negativeButtonProps: {
      size: 'large',
      disabled: loading || false
    },
    onPositiveClick: () => confirm && confirm(),
    onNegativeClick: () => cancel && cancel()
  })
}
